﻿
using System.Web.Http;
using Newtonsoft.Json.Linq;
using Seagull.BarTender.Print;
using System;
using System.Runtime.InteropServices;





namespace ConsoleApplication1
{
   
    [RoutePrefix("api/print")]// 获取路由前缀

   public class printController: ApiController
    {
       
        public static Engine engine = null; // The BarTender Print Engine
        [HttpGet]
        [Route("test")]
        public string getPrint()
        {
            try
            {
                engine = new Engine(true);
            }
            catch (PrintEngineException exception)
            {

                Console.Write(exception.Message);
                return null;

            }

            return "开启engine实例成功!!!";
        }

        [HttpPost]
            [Route("{doc_no}")]
        public string getPrint(string doc_no)
            {
            printServiceImpl ps = new printServiceImpl();
          string doc =  ps.printUpLabel(doc_no);
                return "工单单号为:"+doc;
            }

        [HttpPost]
        [Route("two")]
        public string getPrint([FromBody]JObject obj)
        {
            printServiceImpl ps = new printServiceImpl();
            string cc = obj["doc_no"].ToString();
            int dd = (int)obj["copies"];
            string doc = ps.printUpLabel(obj["doc_no"].ToString(),(int)obj["copies"]);


            return "工单单号为:" + doc;
        }
        [HttpPost]
        [Route("oldtoNew")]
        public string oldToNewPrint([FromBody]JObject obj)
        {
            printServiceImpl ps = new printServiceImpl();
            string cc = obj["doc_no"].ToString();
          //  int dd = (int)obj["copies"];
            string doc = ps.oldtoNew(obj["doc_no"].ToString(), obj["copies"].ToString());


            return "工单单号为:" + doc;
        }




        [HttpGet]
        [Route("user/{username}")]
        public string login(string username)
        {
            string result = "";
            result = username + "88888";


            return result;
        }
    }
}
